package com.roc.web.timer;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.TimerTask;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.roc.service.IMerchantServices;
import com.roc.util.Constance;

@Component
public class ScheduleTask extends TimerTask {
    private static	Logger logger=Logger.getLogger(ScheduleTask.class);
	 
	private long times=0;
	
	@Autowired
	IMerchantServices merchantServices;
	
	public ScheduleTask(){
		
	}
	@Override
	public void run() {
		//加入处理业务逻辑的方法
		String dateStr="";
		logger.info("#############操作员密码错误次数清零第 【"+(++times) +"】次任务开始执行#############");
		try {
			Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
			
			Date date=null;
			
			date=calendar.getTime();
			dateStr=Constance.formateDate(date, "yyyyMMdd");
			
			int total=merchantServices.initOpePwdErrTimes();
			
			logger.info("#############操作员密码错误次数清零第定时器【"+dateStr+"】第 【"+(times) +"】次执行任务成功,总计解锁【"+total+"】个#############");		
			
		} catch (Exception e) {
			logger.error("############操作员密码错误次数清零定时器 【"+dateStr+"】 第 【"+(times) +"】 次执行任务失败#############",e);
			e.printStackTrace();
			
		}
		

	}
	
	
	
	public static void main(String[] args) {
		ScheduleTask st= new ScheduleTask();
		
		System.out.println("----------------------------");
	}
}
